﻿using System;
using ltModel;
using Telerik.Web.UI;

public partial class ltMan_links_linkTypeList : AdminBasePage
{
    ltModel.BLL.join_sort joins = new ltModel.BLL.join_sort();

    protected void Page_Load(object sender, EventArgs e)
    {
        SqlPager pager = new SqlPager("lt_join_sort", "jid", "*");
        if (!string.IsNullOrEmpty(sName.Text))
            pager.Where = " [jname] like '%" + sName.Text.Replace("'", "''") + "%'";
        pager.OrderBy = "px asc";
        RadGridBinder.Create(RadGrid1, pager);
    }
    protected void RadGrid1_DeleteCommand(object sender, GridCommandEventArgs e)
    {
        int id = int.Parse(GridCommander.ExtractValue(e, "jid"));
        OperateLog.AddSuccessLog(CurrentUser.user_id, Request.UserHostAddress, "网站类别-删除>" + joins.GetModel(id).jname);
        joins.Delete(id);
        new ltModel.BLL.joins().DeleteJid(id);
    }
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName == "Move")
        {
            int id = Convert.ToInt32(GridCommander.ExtractValue(e, "jid"));
            joins.PxMove(id, e.CommandArgument.ToString());
            OperateLog.AddSuccessLog(CurrentUser.user_id, Request.UserHostAddress, "网站类别-修改顺序>" + joins.GetModel(id).jname);
            RadGrid1.Rebind();
        }
    }
    protected void b1_Click(object sender, EventArgs e)
    {
        RadGrid1.Rebind();
    }
    protected void RadGrid1_UpdateCommand(object sender, GridCommandEventArgs e)
    {
        ltModel.BLL.join_sort jbl = new ltModel.BLL.join_sort();
        ltModel.Model.join_sort jbo = jbl.GetModel(int.Parse(GridCommander.ExtractValue(e, "jid")));
        jbo.jname = GridCommander.ExtractValue(e, "jname");
        jbl.Update(jbo);
        OperateLog.AddSuccessLog(CurrentUser.user_id, Request.UserHostAddress, "网站类别-修改>" + jbo.jname);
    }
    protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
    {
        ltModel.Model.join_sort jbo = new ltModel.Model.join_sort();
        ltModel.BLL.join_sort jbl = new ltModel.BLL.join_sort();
        jbo.jid = 0;
        jbo.jname = DataProtector.ToSBC(GridCommander.ExtractValue(e, "jname"));
        jbo.px = jbl.MaxPx();
        jbl.Add(jbo);
        OperateLog.AddSuccessLog(CurrentUser.user_id, Request.UserHostAddress, "网站类别-添加>" + jbo.jname);
    }
}